package telas.login;

import java.awt.BorderLayout;
import java.awt.FlowLayout;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JProgressBar;
import javax.swing.JLabel;
import javax.swing.ImageIcon;
import java.awt.Canvas;
import java.awt.Color;
import java.awt.Font;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.SwingConstants;

public class DialogCarregar extends JDialog {

	private final JPanel contentPanel = new JPanel();
	private JLabel lblProgress;
	private Task task;
	/**
	 * Launch the application.
	 */
	/**
	 * Create the dialog.
	 */
	public DialogCarregar(Login tela) {
		
		setResizable(false);
//		super(tela);
//		setLocationRelativeTo(tela);
		setVisible(true);
		setTitle("Carregando dados");
		setBounds(100, 100, 450, 300);
		getContentPane().setLayout(new BorderLayout());
		contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
		getContentPane().add(contentPanel, BorderLayout.CENTER);
		contentPanel.setLayout(null);
		{
			JLabel lblNewLabel = new JLabel("");
			lblNewLabel.setBounds(92, 10, 260, 140);
			lblNewLabel.setIcon(new ImageIcon(DialogCarregar.class.getResource("/telas/sistema/figuras/LogoGrande.png")));
			contentPanel.add(lblNewLabel);
		}
		{
			lblProgress = new JLabel("lblProgress");
			lblProgress.setHorizontalAlignment(SwingConstants.CENTER);
			lblProgress.setFont(new Font("Dialog", Font.BOLD, 17));
			lblProgress.setForeground(Color.WHITE);
			lblProgress.setBounds(69, 180, 304, 30);
			contentPanel.add(lblProgress);
		}
		
		JLabel label = new JLabel("");
		label.setIcon(new ImageIcon(DialogCarregar.class.getResource("/telas/sistema/figuras/fundo.jpg")));
		label.setBounds(0, 0, 444, 286);
		contentPanel.add(label);
		{
			JPanel progressPane = new JPanel();
			getContentPane().add(progressPane, BorderLayout.SOUTH);
			progressPane.setLayout(new BorderLayout(0, 0));
			{
				JProgressBar progressBar = new JProgressBar();
				progressBar.setIndeterminate(true);
				progressPane.add(progressBar);
			}
		}
		task = new Task(this, lblProgress);
		task.execute();

		setLocationRelativeTo(tela);
	}
}
